<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>vue交互</title>
    <script src="../jquery.min.js"></script>
    <script src="../vue.js"></script>
    <script src="../vue-resource.js"></script>
</head>
<body>
<div id="box">
    <input type="button" value="按钮" @click="jsonpAjax()">
</div>
<script>
    window.onload = function(){
        new Vue({
            el:"#box",//
            data:{

            },
            methods:{
                get:function(){
                   this.$http.get('aa.txt').then(function (res) {
                       alert(res.data)
                   },function (res) {
                       console.log(res.data)
                   })
                },
                get2:function(){
                    this.$http.get("get.php",{
                        a:1,
                        b:2
                    }).then(function(res){
                        alert(res.data);
                    },function(res){
                        alert(res.data);
                    });
                },
                post:function () {
                    this.$http.pos('post.php',{
                        a:1,
                        b:20
                    },{
                        emulateJSON:true
                    }).then(function(res){
                        alert('成功！');
                    },function (res) {
                        alert('失败');
                    })
                },
                jsonpAjax:function () {
                    this.$http.jsonp('https://www.sogou.com/reventondc/',{
                        key:'d123',
                        type:'2'
                    },{
                        jsonp:'cb'
                    }).then(function (res) {
                        alert(res.data);
                    },function (res) {
                        alert(res.data);
                    })
                }
            }
        })
    }
</script>
</body>
</html>